package com.xiaofeng.Hello;
import java.util.Random;
public class Java8 {
    public static void main(String[] args) {
        //打乱数组中的数据
        Random r=new Random();
        int []arr={3,4,1,2,5};
        System.out.printf("arr数组原来存储的数据：");
        for (int i = 0; i < arr.length; i++) {
            System.out.printf("%d ",arr[i]);
        }
        System.out.printf("\n");

        for (int i = 0; i < arr.length; i++) {
            int index=r.nextInt(arr.length);
            int tmp=arr[index];
            arr[index]=arr[i];
            arr[i]=tmp;
        }
        System.out.printf("arr数组现在存储的数据：");
        for (int i = 0; i < arr.length; i++) {
            System.out.printf("%d ",arr[i]);
        }
        System.out.printf("\n");
    }
}
